//
//  OrderViewController.m
//  jingjing2.0
//
//  Created by apple on 16/4/27.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "OrderViewController.h"
#define  INTERVAL kWidth/3.0
@interface OrderViewController ()
{
    UIImageView *_imageView;
    UILabel *_tipLbl;
    UIView *_lineView;
    NSInteger _selectedCtl;
}

@end

@implementation OrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title=@"订单中心";
    [self setUpBgView];
    [self setUpLineView];
    [self setUpSegmentControl];
}
#pragma mark--创建没有拼单活动
-(void)setUpBgView
{
    _imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"no_order"]];
    _imageView.center=self.view.center;
    //_imageView.hidden=YES;
    _imageView.bounds=CGRectMake(0, 5, 80, 80);
    [self.view addSubview:_imageView];
    
    _tipLbl=[[UILabel alloc]init];
    _tipLbl.center=CGPointMake(_imageView.center.x+40, _imageView.center.y+40+30);
    _tipLbl.bounds=CGRectMake(0, 0, 250, 30);
    _tipLbl.text=@"净净在等你，快来下单吧！";
    _tipLbl.textColor=GRAYCOLOR;
    //_tipLbl.hidden=YES;
    [self.view addSubview:_tipLbl];
}
#pragma mark--小蓝条
-(void)setUpLineView
{
    _lineView=[[UIView alloc]initWithFrame:CGRectMake(0, 64+30, INTERVAL, 1)];
    _lineView.backgroundColor=BLUECOLOR;
    [self.view addSubview:_lineView];
}
#pragma mark---选择条
-(void)setUpSegmentControl
{
//    去支付（未支付）根据isShowPayBtn判断是否要支付，不然就显示邀请返利
//    邀请返利 去评价（已支付，未评价）根据。。判断是否已评价
//    邀请返利 砸彩蛋（评价完了，就会送一颗蛋）根据。。判断是否已砸单
//    邀请返利  (已支付已评价已砸单或者订单未完成)
//    邀请返利 追加支付 （追加支付金额还有payUp）
//    线下支付的不需要显示去支付，只要邀请返利
    for (int i=0; i<3; i++) {
        UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(i*INTERVAL,64,INTERVAL,30)];
        btn.backgroundColor=[UIColor whiteColor];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        btn.titleLabel.font=[UIFont systemFontOfSize:15];
        if (i==0)
        {
            [btn setTitle:@"待支付" forState:UIControlStateNormal];
            [btn setTitleColor:BLUECOLOR forState:UIControlStateNormal];
            btn.tag=1;
            _selectedCtl=btn.tag;
        }else if(i==1)
        {
            btn.tag=2;
            [btn setTitle:@"服务中" forState:UIControlStateNormal];
        }else
        {
            btn.tag=3;
            [btn setTitle:@"已完成" forState:UIControlStateNormal];
        }
        
        [btn addTarget:self action:@selector(clickOnControl:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
    }
}
-(void)clickOnControl:(UIButton *)btn
{
    if (_selectedCtl==btn.tag)
    {
        return;
    }
    UIButton *lastBtn=[self.view viewWithTag:_selectedCtl];
    [lastBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn setTitleColor:BLUECOLOR forState:UIControlStateNormal];
    [UIView animateWithDuration:0.1 animations:^{
        _lineView.frame=CGRectMake(btn.frame.origin.x, btn.frame.origin.y+30, INTERVAL, 1);
    }];
    _selectedCtl=btn.tag;
    //[self getDataWithSpellStatus:[NSString stringWithFormat:@"%ld",(long)_selectedCtl]];
    
}

@end
